CREATE TABLE Category
(
  CategoryId    VARCHAR2(150)   NOT NULL,
  Name    VARCHAR2(150)   NOT NULL,
  Descn    VARCHAR2(150)   NULL,
    CONSTRAINT PK_Category PRIMARY KEY (CategoryId)
)
/

CREATE TABLE Inventory
(
  ItemId    VARCHAR2(150)   NOT NULL,
  Qty    NUMBER(10)   NOT NULL,
    CONSTRAINT PK_Inventory PRIMARY KEY (ItemId)
)
/

CREATE TABLE Item
(
  ItemId    VARCHAR2(150)   NOT NULL,
  ProductId    VARCHAR2(150)   NOT NULL,
  ListPrice    NUMBER(30)   NULL,
  UnitCost    NUMBER(30)   NULL,
  Supplier    NUMBER(10)   NULL,
  Status    VARCHAR2(150)   NULL,
  Name    VARCHAR2(150)   NULL,
  Image    VARCHAR2(150)   NULL,
    CONSTRAINT PK_Item PRIMARY KEY (ItemId)
)
/

CREATE TABLE Product
(
  ProductId    VARCHAR2(150)   NOT NULL,
  CategoryId    VARCHAR2(150)   NOT NULL,
  Name    VARCHAR2(150)   NULL,
  Descn    VARCHAR2(150)   NULL,
  Image    VARCHAR2(150)   NULL,
    CONSTRAINT PK_Product PRIMARY KEY (ProductId)
)
/

CREATE TABLE Supplier
(
  SuppId    NUMBER(10)   NOT NULL,
  Name    VARCHAR2(150)   NULL,
  Status    VARCHAR2(150)   NOT NULL,
  Addr1    VARCHAR2(150)   NULL,
  Addr2    VARCHAR2(150)   NULL,
  City    VARCHAR2(150)   NULL,
  State    VARCHAR2(150)   NULL,
  Zip    VARCHAR2(150)   NULL,
  Phone    VARCHAR2(150)   NULL,
    CONSTRAINT PK_Supplier PRIMARY KEY (SuppId)
)
/

CREATE SEQUENCE Supplier_SuppId_SEQ
START WITH 1
INCREMENT BY 1
/

CREATE OR REPLACE TRIGGER Supplier_SuppId_TRIGGER
  BEFORE INSERT
  ON Supplier
  REFERENCING OLD AS OLD NEW AS NEW
  FOR EACH ROW   
BEGIN   
  SELECT Supplier_SuppId_SEQ.NEXTVAL INTO :NEW.SuppId FROM DUAL;
END;
/

CREATE TABLE DAC_ISSUE
(
  ISSUE_ID    NUMBER(10)   NOT NULL,
  ISSUE_TITLE    VARCHAR2(255)   NOT NULL,
  ISSUE_DESC    VARCHAR2(2000)   NULL,
  ISSUE_STS    NUMBER(10)   NOT NULL,
  ISSUE_TYP    VARCHAR2(50)   NULL,
  ISSUE_OWNR    VARCHAR2(50)   NULL,
  ISSUE_PRGS    NUMBER(18, 2)   NULL,
  CREATE_TM    DATE   NOT NULL,
  ISSUE_LOCKED    NUMBER(10)   NULL,
    CONSTRAINT PK_DAC_ISSUE PRIMARY KEY (ISSUE_ID)
)
/

CREATE SEQUENCE DAC_ISSUE_ISSUE_ID_SEQ
START WITH 1
INCREMENT BY 1
/

CREATE OR REPLACE TRIGGER DAC_ISSUE_ISSUE_ID_TRIGGER
  BEFORE INSERT
  ON DAC_ISSUE
  REFERENCING OLD AS OLD NEW AS NEW
  FOR EACH ROW   
BEGIN   
  SELECT DAC_ISSUE_ISSUE_ID_SEQ.NEXTVAL INTO :NEW.ISSUE_ID FROM DUAL;
END;
/

CREATE TABLE DAC_USER
(
  USER_ID    VARCHAR2(50)   NOT NULL,
  USERNAME    VARCHAR2(50)   NOT NULL,
  FULLNAME    VARCHAR2(255)   NULL,
  USER_PWD    VARCHAR2(50)   NULL,
  CHANGINGPWD    NUMBER(10)   NULL,
  USERLOCKED    NUMBER(10)   NULL,
  LASTLOGIN    DATE   NULL,
  USER_DESC    VARCHAR2(2000)   NULL,
    CONSTRAINT PK_DAC_USER PRIMARY KEY (USER_ID)
)
/

CREATE TABLE DAC_MUTIPLEKEYS
(
  DAC_KEY1    VARCHAR2(50)   NOT NULL,
  DAC_KEY2    VARCHAR2(50)   NOT NULL,
  DAC_VALUE1    VARCHAR2(50)   NULL,
  DAC_VALUE2    VARCHAR2(50)   NULL,
    CONSTRAINT PK_DAC_MUTIPLEKEYS PRIMARY KEY (DAC_KEY1, DAC_KEY2)
)
/

